/*
 * Copyright 2012-2014 Manlost.com All right reserved. This software is the confidential and proprietary information of
 * Manlost.com ("Confidential Information"). You shall not disclose such Confidential Information and shall use it only
 * in accordance with the terms of the license agreement you entered into with Manlost.com.
 */
package com.manlost.biz.account.impl.dao.impl;

import java.util.List;

import org.springframework.stereotype.Repository;

import com.manlost.biz.account.impl.dao.interfaces.AccountDAO;
import com.manlost.biz.account.model.dataobject.Account;
import com.manlost.biz.account.query.ListAccountQuery;
import com.manlost.biz.common.ibatis.BaseSqlMapClientDaoSupport;

/**
 * AccountDao实现
 * @author kang.zhouk
 */
@SuppressWarnings("unchecked")
@Repository
public class AccountDAOImpl extends BaseSqlMapClientDaoSupport implements AccountDAO {

    public List<Account> listAccount(ListAccountQuery query) {
        return (List<Account>) getSqlMapClientTemplate().queryForList("account.listAccount", query);
    }

    @Override
    public Account findAccount(String email) {
        return (Account) getSqlMapClientTemplate().queryForObject("account.find", email);
    }

    @Override
    public Account createAccount(Account account) {
        getSqlMapClientTemplate().insert("account.insert", account);
        return findAccount(account.getEmail());
    }
}
